import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        File file = new File(".\\src\\hello.txt");
        try(FileReader fr = new FileReader(file)){
            char[] buf = new char[5];
            //记录每次读入的字符个数
            int len;
            while ((len =fr.read(buf)) != -1){
                for (int i = 0; i < len; i++) {
                    System.out.print(buf[i]);
                }
            }
        }
    }
}
